package com.lxs.legou.pay.interceptor;

import com.lxs.legou.pay.utils.AdminToken;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @Auther: Mcb
 * @Date: 2022/1/16 16:50
 * @Description: feing拦截器
 */
@Component
public class MyFeignInterceptor implements RequestInterceptor {

    @Override
    public void apply(RequestTemplate requestTemplate) {
        String token = null;

        try {
            token = AdminToken.adminToken();
        } catch (IOException e) {
            e.printStackTrace();
        }

        requestTemplate.header("Authorization","Bearer "+token);
    }
}
